<?php
declare (strict_types=1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Dashboard extends BaseModel
{
    protected $name = 'dashboard';

    public function setElectricAttr($value): bool|string
    {
        return json_encode($value, 320);
    }

    public function setSensorAttr($value): bool|string
    {
        return json_encode($value, 320);
    }

    public function getElectricAttr($value)
    {
        return json_decode($value);
    }

    public function getSensorAttr($value)
    {
        return json_decode($value);
    }

    public function stock()
    {
        return $this->hasOne(Stock::class, 'id', 'stock_id');
    }
}
